﻿@{
    ViewData["Title"] = "我报审的文件";
}

<div class="content-top-nav">
    <h3 style="color:#444"><i class="layui-icon layui-icon-home"></i> @ViewData["Title"] </h3>
    <hr>
</div>
<div class="layui-fluid" style="margin-bottom:50px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form class="layui-form" action="" lay-filter="FormSearch" enctype="multipart/form-data">
                    <div class="layui-card-body ">
                        <div class="layui-form">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="title" id="title" placeholder="按标题搜索" class="layui-input" style="width:220px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="remarks" id="remarks" placeholder="审核意见" class="layui-input" style="width:240px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block" style="width:120px;">
                                <select id="status" name="status" lay-verify="required">
                                    <option value="">审核状态</option>
                                    <option value="1">已审</option>
                                    <option value="0">未审</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block" style="width:120px;">
                                <select id="pass" name="pass" lay-verify="required">
                                    <option value="">通过状态</option>
                                    <option value="2">已办结</option>
                                    <option value="1">通过</option>
                                    <option value="0">未通过</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" data-type="reload" id="searchBtn"><i class="layui-icon">&#xe615;</i></button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>

            <table class="layui-hide" id="currentTableId" lay-data="{id: 'idReload'}" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="statusTpl">
                 {{#  if(d.status == 0){ }}
                  <b style="color:#FF5722;">未审核</b>
                {{#  } else if(d.status==1) { }}
                  <b style="color:#5FB878;">已审</b>
                {{#  } }}
            </script>
            <script type="text/html" id="passTpl">
                          {{#  if(d.pass == 0){ }}
                           <b style="color:#FF5722;">未通过</b>
                         {{#  } else if(d.pass==1) { }}
                           <b style="color:#5FB878;">通过</b>
                {{#  } else if(d.pass==2) { }}
                  <b style="color:#1E9FFF;">已办结</b>
                {{#  } }}
            </script>
            <script type="text/html" id="examineTimeTpl">
                {{# if(d.exaTime === "0001-01-01"){  }}
                {{# }else{  }}
               {{ d.exaTime}}
                {{# } }}
            </script>
            <script type="text/html" id="remarksTpl">
                <span style="color:#1E9FFF;">{{d.remarks}}</span>
            </script>
            <script type="text/html" id="contentUrlTpl">
                <a lay-event="edit">{{d.title}}</a>
            </script>
            <script type="text/html" id="currentTableBar">
                <div class="layui-btn-group">
                    @if (await Authorizer.AuthView(PermissionKeys.ArticleExamine_Post))
                    {
                                <a class="layui-btn layui-btn-warm" lay-event="postExamine"><i class="layui-icon">&#xe613;</i>流转审核</a>
                    }
                </div>
            </script>

        </div>
    </div>
</div>

<script>
    layui.define(function () {
        var table = layui.table, $ = layui.jquery, layer = layui.layer, form = layui.form;
        form.render();

        table.render({
            elem: '#currentTableId',
            url: '/Admin/Examine/PostIndex?json=1',
            toolbar: false,
            lineStyle: 'height:70px;',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            page: { 
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                , groups: 2 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
            },
            cols: [[
                { field: 'id', width: 80, title: '序号', sort: true },                
                { field: 'title', title: '标题', templet: '#contentUrlTpl' },
                { field: 'insertTime', width: 180, title: '提交时间', sort: true },
                { field: 'examine', width: 180, title: '审核人'},
                { field: 'status', width: 80, title: '状态', align: 'center', templet: '#statusTpl' },
                { field: 'pass', width: 80, title: '通过', align: 'center', templet: '#passTpl' },
                { field: 'exaTime', width: 180, title: '审核时间', align: 'center', templet: '#examineTimeTpl' },
                { field: 'remarks', width: 320, title: '审核意见', templet: '#remarksTpl' },
                { title: '操作', width: 260, templet: '#currentTableBar', fixed: "right", align: "left" }
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            id: 'tableReload',
            page: true
        });


        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'postExamine') {
                var index = layer.open({
                    type: 2,
                    title: ['审核流转', 'font-size:18px;'],
                    area: ['1200px', '700px'],
                    shadeClose: "true",
                    content: '/Admin/Examine/PostExamineById?id=' + data.id
                });
            }
        });

        //搜索重载表格
        $('#searchBtn').on('click', function () {
            table.reloadData('tableReload', {
                method: 'get',
                where: {
                    Title: $('#title').val(),
                    Remarks: $('#remarks').val(),
                    Status: $('#status').val(),
                    Pass: $('#pass').val(),
                },
                page: {
                    curr: 1
                },
                page: true,
            });
            return false;
        });
    });
</script>